queryList()


function queryList() {
    let xhr = new XMLHttpRequest();
    xhr.open("GET", "http://localhost:8080/weapon_sys_war_exploded/query", true)
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
            console.log(xhr.responseText)
            addItems(JSON.parse(xhr.responseText))
        }
    }
    xhr.send()
}


// addItems([{"att":200,"id":1,"name":"AK-47","remake":"连发步枪"},{"att":20,"id":2,"name":"青龙偃月刀","remake":"手持砍刀"}])

function addItems(list) {
    let content = document.getElementById("content");
    let html = ""
      for (let i = 0; i < list.length; i++) {
          let item = list[i];
          let strTemplate = `
          <div class="item">
                <img src="item-img.jpg" height="160px" width="160px"/>
                <br>
                <span>${item.name}</span>
                <br>
                <span>${item.remake}</span>
            </div>
          `;
          html += strTemplate;
      }
    content.innerHTML=html
}
